package com.itheima.sc.impl.cms;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.sc.api.cms.SubjectProductRelationApi;
import com.itheima.sc.mapper.cms.SubjectProductRelationMapper;
import com.itheima.sc.pojo.cms.SubjectProductRelation;
import org.apache.dubbo.config.annotation.DubboService;

import java.util.List;

@DubboService
public class SubjectProductRelationImpl extends ServiceImpl<SubjectProductRelationMapper, SubjectProductRelation> implements SubjectProductRelationApi {
    @Override
    public List<SubjectProductRelation> getByPid(Integer id) {
        LambdaQueryWrapper<SubjectProductRelation> wrapper = new LambdaQueryWrapper<SubjectProductRelation>().eq(SubjectProductRelation::getProductId, id);
        return list(wrapper);
    }

    @Override
    public void removeByPid(Integer pid) {
        LambdaQueryWrapper<SubjectProductRelation> wrapper = new LambdaQueryWrapper<SubjectProductRelation>().eq(SubjectProductRelation::getProductId, pid);
        remove(wrapper);
    }
}
